//
//  ZYGonggongTableViewController.swift
//  ZYweibo
//
//  Created by 张耀 on 16/6/26.
//  Copyright © 2016年 zhangyao. All rights reserved.
//

import UIKit

class ZYGonggongTableViewController: UITableViewController {

    //用户是否登录
    let login: Bool = false
    
    //访客视图对象
    var fangkeView: ZYFangkeView?
    
    override func loadView() {
        
        //登录
        if login{
            
        super.loadView()
        
        }else{
        
            //未登录
            setuoVisitorView()
        }
    }
    
    // MARK: -设置访客视图
    private func setuoVisitorView(){
        
        daohanglan()
        
        fangkeView = ZYFangkeView()
        
        fangkeView?.cloure = {
        
        [weak self] in self?.jiantingClick()
            
        }
        view = fangkeView
    
    
    }
    
    // MARK: -设置导航栏
    private func daohanglan(){
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "jiantingClick")
    
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "jiantingClick")
        
    }
    
    
    // MARK: - 监听方法
    
    @objc private func jiantingClick(){
    
        //弹出登录控制器
        
        let oauthVC = ZYOAuthViewController()
        
        let naVC = UINavigationController(rootViewController: oauthVC)
        
        presentViewController(naVC, animated: true, completion: nil)
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
}
